package com.galengao.springboot.excel.enrity;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.ContentStyle;
import com.galengao.springboot.excel.converter.UserConverter;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;

/**
 * excel user 对象
 *
 * @author GalenGao
 * @version Id: UserDto.java, v 0.1 2022/6/5 16:33 GalenGao Exp $$
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@ExcelIgnoreUnannotated // 过滤没有加@ExcelProperty注解的字段
public class UserDto {

    @ExcelProperty(index = 0,value = "姓名")
    private String userName;

    @ExcelProperty(index = 1,value = "年龄")
    private Integer age;

    @DateTimeFormat("yyyy-MM-dd")
    @ExcelProperty(index = 2,value = "生日")
    private Date birthday;

    @ExcelProperty(index = 3,value = "性别",converter = UserConverter.class)
    private Integer sex;

    @ExcelProperty(index = 4,value = "体重")
//    @NumberFormat("0.##")
    @ContentStyle(dataFormat = 2)
    private BigDecimal weight;

    @ExcelProperty(index = 5,value = "备注")
    private String remark;
}
